package com.example.rbm;

import com.example.consts.RbmConsts;
import com.example.service.SearchKeywordService;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 本文来演示
 *
 * @author 赵建云
 * @create 2023/10/14
 */
@Component
public class RbmSearch {
    @Autowired
    private SearchKeywordService searchKeywordService;
    @RabbitHandler
    @RabbitListener(queues = RbmConsts.ROOTING_DH_SEARCH)
    public void saveSearchKey(String searchKey){
        String[] search = searchKey.split(",");
        Integer jsId = Integer.valueOf(search[0]);
        String searchKeyword = search[1];
//        Integer jsId = 1;
//        String searchKeyword = "";
        System.out.println(jsId);
        System.out.println(searchKeyword);
        searchKeywordService.saveSearch(jsId,searchKeyword);
    }
}
